// Functions

// Clip
void  clip(in float x)		{ if ( x < 0.0 ) discard; }
void  clip(in vec2  x)		{ if ( any( lessThan( x, vec2(0.0) ) ) ) discard; }
void  clip(in vec3  x)		{ if ( any( lessThan( x, vec3(0.0) ) ) ) discard; }
void  clip(in vec4  x)		{ if ( any( lessThan( x, vec4(0.0) ) ) ) discard; }

// Saturate
float saturate(in float x)	{ return clamp( x, 0.0, 1.0 ); }
vec2  saturate(in vec2  x)	{ return clamp( x, 0.0, 1.0 ); }
vec3  saturate(in vec3  x)	{ return clamp( x, 0.0, 1.0 ); }
vec4  saturate(in vec4  x)	{ return clamp( x, 0.0, 1.0 ); }

// LengthSqr
float lengthSqr(in float x)	{ return x*x; }
vec2  lengthSqr(in vec2  x)	{ return dot( x, x ); }
vec3  lengthSqr(in vec3  x)	{ return dot( x, x ); }
vec4  lengthSqr(in vec4  x)	{ return dot( x, x ); }

// DistanceSqr
float distanceSqr(in float x, in float y)	{ return lengthSqr( x - y ); }
float distanceSqr(in vec2  x, in vec2  y)	{ return lengthSqr( x - y ); }
float distanceSqr(in vec3  x, in vec3  y)	{ return lengthSqr( x - y ); }
float distanceSqr(in vec4  x, in vec4  y)	{ return lengthSqr( x - y ); }
